]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
util: Wrap g_regex_escape_string()
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 23 Jun 2017 18:12:38 +0000 (20:12 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 14 Jul 2017 20:40:25 +0000 (22:40 +0200)
src/shell-util.c
src/shell-util.h

index bedd5869b03a8f53cb984031e7aba98a4f2628b5..7383e8423c2c6e5423c6c34cc2aa772c7c40dc4b 100644 (file)
@@ -240,6 +240,21 @@ shell_util_translate_time_string (const char *str)
   return res;
 }
 
+/**
+ * shell_util_regex_escape:
+ * @str: a UTF-8 string to escape
+ *
+ * A wrapper around g_regex_escape_string() that takes its argument as
+ * \0-terminated string rather than a byte-array the confuses gjs.
+ *
+ * Returns: @str with all regex-special characters escaped
+ */
+char *
+shell_util_regex_escape (const char *str)
+{
+  return g_regex_escape_string (str, -1);
+}
+
 /**
  * shell_write_string_to_stream:
  * @stream: a #GOutputStream
index 532e19ba9f3bd16622a004dd228d5e811049d961..2218594c19ed2c5c624bc5941417675b2f2bc7ec 100644 (file)
@@ -24,6 +24,8 @@ char    *shell_util_format_date                (const char       *format,
                                                 gint64            time_ms);
 const char *shell_util_translate_time_string   (const char *str);
 
+char    *shell_util_regex_escape               (const char *str);
+
 gboolean shell_write_string_to_stream          (GOutputStream    *stream,
                                                 const char       *str,
                                                 GError          **error);